<template>
  <div>
    <div>
      <el-button type="primary" @click="gobb()">报表</el-button>
      <!-- <button @click="gobb()">报表</button> -->
      <div class="top">
        <div>
          <span>部门:</span>
          <div >
            <el-checkbox-group v-model="checked1" size="large" >
              <el-checkbox :label="item.name"  :value="item.id"  v-for="item in Bm" :key="item.id" @change="change(item.id)"/>
            </el-checkbox-group>
          </div>
        </div>
      </div>
      <div class="top">
        <div>
          <span>社保城市:</span>
          <div >
            <el-checkbox-group v-model="checked2" size="large" >
              <el-checkbox :label="item.name"  :value="item.id"  v-for="item in city" :key="item.id" @change="change(item.id)"/>
            </el-checkbox-group>
          </div>
        </div>
      </div>
      <div class="top">
        <div>
          <span>公积金城市</span>
          <div >
            <el-checkbox-group v-model="checked3" size="large" >
              <el-checkbox :label="item.name"  :value="item.id"  v-for="item in city" :key="item.id" @change="change(item.id)"/>
            </el-checkbox-group>
          </div>
        </div>
      </div>
    </div>
    <el-table :data="data" height="auto" style="width: 100%" @row-click="go">
      <el-table-column prop="id" label="序号" />
      <el-table-column prop="username" label="姓名" />
      <el-table-column prop="mobile" label="手机号" />
      <el-table-column prop="workNumber" label="工号" />
      <el-table-column prop="departmentName" label="部门" />
      <el-table-column prop="timeOfEntry" label="入职时间" />
      <el-table-column prop="" label="离职时间" />
      <el-table-column prop="participatingInTheCity" label="社保城市" />
      <el-table-column prop="socialSecurityBase" label="社保基数" />
      <el-table-column prop="providentFundBase" label="公积金基数" />
    </el-table>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { getSocial, getCity, getBm } from '../api/axios.js'
import { useRouter } from 'vue-router';
const checked1 = ref([])
const checked2 = ref([])
const checked3 = ref([])
let data = ref([])
let city = ref([])
let Bm = ref([])
let departmentChecks=ref([])
let socialSecurityChecks=ref([])
let providentFundChecks=ref([])
let page=ref('1')
let pagSize=ref('10')
const change = async (i) => {
  departmentChecks.value=checked1.value
  socialSecurityChecks.value=checked2.value
  providentFundChecks.value=checked3.value
  let obj={
    page:page.value,
    pageSize:pagSize.value,
    departmentChecks:departmentChecks.value,
    socialSecurityChecks:socialSecurityChecks.value,
    providentFundChecks:providentFundChecks.value
  }
  let res=await getSocial(obj)
  data.value=res.data.data.rows
}
const router=useRouter()
let go=(row)=>{
  console.log(row);
  router.push(`/socialD?id=${row.id}`)
}
const get = async () => {
  let res = await getSocial()
  let res1 = await getCity()
  let res2 = await getBm()
  data.value = res.data.data.rows
  city.value = res1.data.data
  Bm.value = res2.data.data
}
const gobb=()=>{
  router.push('/statement')
}
onMounted(() => {
  get()
})

</script>

<style scoped>
.top {
  display: flex;
  margin-top: 20px;
  flex-wrap: wrap;
}

.top li {
  list-style: none;
  margin: 20px 10px;
  
}
</style>